/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


onload = function() {
    
    /* set interval of time elapset to change document.title */
    setInterval("app.setTitle('Kepp control of time')", setTitle);
    
    setInterval("app.getTitle('Control-Time-Flow')", getTitle);
    /* end interval of time elapsed to change document.title */


    $("#reg_user").click(function(e) {
        e.preventDefault();

        var username = $("#username").val();
        var password = $("#password").val();
        var password2 = $("#password2").val();
        var email = $("#email").val();
        var firstname = $("#firstname").val();
        var lastname = $("#lastname").val();
        
        if(username == "" || password == "" || password2 == "" || email == "" || firstname == "" || lastname == "" && password != password2) {
            alert("Tomma fält");
        }
        else {
            $.ajax({
                url: processFile,
                type: "POST",
                data: {"check": "users", "username": username, "password": password, "password2": password2, "email": email, "firstname": firstname, "lastname": lastname},
                success: function(data) {
                    alert("Du är nu registrerad, vänligen logga in");
                    document.location = "";
                },
                error: function(msg) {
                    alert(msg);
                }
            });
        }
    });
    
    
    
    
    
    
    
}